package cn.zorbus.laian.infrastructure.config;

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.servers.Server;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * create in 2023/12/16 17:00
 *
 * @author shishaodong
 * @version 0.0.1
 */
@Configuration
public class OpenConfig {

    @Bean
    public OpenAPI springShopOpenAPI() {
        return new OpenAPI()
                .info(new Info().title("来安 API")
                        .description("来安")
                        .version("v0.0.1")
                        .license(new License().name("Apache 2.0").url("http://springdoc.org"))
                )
                .externalDocs(new ExternalDocumentation()
                        .description("来安 Wiki Documentation")
                        .url("https://springshop.wiki.github.org/docs")
                )
                .servers(List.of(publicServer()))
                ;
    }

    private @NotNull Server publicServer() {
        Server server = new Server();
        server.setUrl("https://laian.zorbus.cn/api");
        return server;
    }
}
